#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:lxl

import tkinter as tk  # 使用Tkinter前需要先导入


class Window:

    def __init__(self, title, geometry):
        self.title = title
        self.geometry = geometry

    @staticmethod
    def radio(self):
        window = tk.Tk()
        window.title(self.title)
        window.geometry(self.geometry)

        var = tk.StringVar()
        lb = tk.Label(text="show radio text", bg="yellow", width=20)
        lb.pack()

        def print_selection():
            lb.config(text='you have selected ' + var.get())

        radio1 = tk.Radiobutton(window, text="Option A", value="A", variable=var, command=print_selection)
        radio2 = tk.Radiobutton(window, text="Option B", value="B", variable=var, command=print_selection)
        radio1.pack()
        radio2.pack()

        window.mainloop()


if __name__ == '__main__':
    r = Window(title="Radio", geometry="500x300")
    r.radio(r)
